
const CompressionWebpackPlugin = require('compression-webpack-plugin')

module.exports = {
    productionSourceMap: false,
    devServer: {
        proxy: {
            '/jokeApi': {
                target: 'http://v.juhe.cn/joke/randJoke.php?key=82faecadb02097887bb50fd8bfc20597',
                changOrigin: true,
                ws: true,
                pathRewrite: {
                    '^/jokeApi': ''
                }
            },
            '/weatherApi': {
                target: 'https://restapi.amap.com/v3/weather/weatherInfo',
                changOrigin: true,
                ws: true,
                pathRewrite: {
                    '^/weatherApi': ''
                }
            },
            '/ipApi': {
                target: 'https://restapi.amap.com/v3/ip?output=JSON&key=f09aa99a0f160728175a740815e044ac',
                changOrigin: true,
                ws: true,
                pathRewrite: {
                    '^/ipApi': ''
                }
            }
        },
        // https: true
    },
    configureWebpack: config => {
        // 开发环境不需要gzip
        if (process.env.NODE_ENV !== 'production') return
        config.plugins.push(
            new CompressionWebpackPlugin({
                // 正在匹配需要压缩的文件后缀
                test: /\.(js|css|svg|woff|ttf|json|html)$/,
                // 大于10kb的会压缩
                threshold: 10240
                // 其余配置查看compression-webpack-plugin
            })
        )
    }
}




// location /ipApi/ {
//     proxy_pass  https://restapi.amap.com/v3/ip?output=JSON&key=f09aa99a0f160728175a740815e044ac;
// }


// location /weatherApi/ {
//     proxy_pass  https://restapi.amap.com/v3/weather/weatherInfo;
// }


// location /jokeApi/ {
//     proxy_pass  http://api.avatardata.cn/Joke/NewstJoke?key=6f667b97a3f341baa44bd44daa136367&page=1&rows=10;
// }